<?php
namespace app\admin\controller;

use app\model\Admin;
use app\model\Config;
use app\BaseController;
use app\model\Permissions;
use app\model\Roles;
use think\App;


class User extends BaseController
{
//$mobile = $this->app->make('admin_id');

    /**
     * 管理员登陆
     */
    public function  admin_login(){
        $param  =  request()->param();
        $adminModel =  new Admin();
        $result =  $adminModel->adminLogin($param);
        return $result;
    }

    /**
     * 管理员退出登陆
     */
    public function  admin_login_out(){
        $admin_id = $this->app->make('admin_id');
        $param  =  request()->param();
        $param['admin_id'] = $admin_id;
        $adminModel = new Admin();
        $result =  $adminModel->adminLoginOut($param);
        return $result;
    }

    /**
     * 新增编辑管理员
     */
    public function  add_edit_admin(){
        $admin_id = $this->app->make('admin_id');
        $param  =  request()->param();
        $param['admin_id'] = $admin_id;
        $adminModel = new Admin();
        $result = $adminModel->addEditAdmin($param);
        return $result;
    }

    /**
     * 管理员列表
     */
    public function  admin_list(){
        $admin_id = $this->app->make('admin_id');
        $param  =  request()->param();
        $param['admin_id'] = $admin_id;
        $adminModel =  new Admin();
        $result = $adminModel->adminList($param);
        return $result;
    }
    /**
     * 删除管理员
     */
    public function  del_admin(){
        $admin_id = $this->app->make('admin_id');
        $param  =  request()->param();
        $param['admin_id'] = $admin_id;
        $adminModel =  new Admin();
        $result = $adminModel->delAdmin($param);
        return $result;
    }


    /**
     * 角色列表
     */
    public function  role_list(){
        $admin_id = $this->app->make('admin_id');
        $param  =  request()->param();
        $param['admin_id'] = $admin_id;
        $rolesModel =  new Roles();
        $result = $rolesModel->roleList($param);
        return $result;
    }


    /**
     * 获取所有角色列表
     */
    public function  all_role_list(){
        $admin_id = $this->app->make('admin_id');
        $param  =  request()->param();
        $param['admin_id'] = $admin_id;
        $rolesModel =  new Roles();
        $result = $rolesModel->allRoleList($param);
        return $result;
    }

    /**
     * 删除角色
     */
    public function  del_role(){
        $admin_id = $this->app->make('admin_id');
        $param  =  request()->param();
        $param['admin_id'] = $admin_id;
        $rolesModel =  new Roles();
        $result = $rolesModel->delRole($param);
        return $result;
    }

    /**
     * 添加编辑角色
     */
    public function  add_edit_role(){
        $admin_id = $this->app->make('admin_id');
        $param  =  request()->param();
        $param['admin_id'] = $admin_id;
        $rolesModel =  new Roles();
        $result = $rolesModel->addEditRole($param);
        return $result;
    }


    /**
     * 添加编辑权限
     */
    public function  add_edit_permission(){
        $admin_id = $this->app->make('admin_id');
        $param  =  request()->param();
        $param['admin_id'] = $admin_id;
        $permissionsModel =  new Permissions();
        $result = $permissionsModel->addEditPermission($param);
        return $result;
    }

    /**
     * 权限详情
     */
    public function  permission_detail(){
        $admin_id = $this->app->make('admin_id');
        $param  =  request()->param();
        $param['admin_id'] = $admin_id;
        $permissionsModel =  new Permissions();
        $result = $permissionsModel->permissionDetail($param);
        return $result;
    }

    /**
     * 管理员详情
     */
    public function  admin_detail(){
        $admin_id = $this->app->make('admin_id');
        $param  =  request()->param();
        $param['admin_id'] = $admin_id;
        $adminModel =  new Admin();
        $result = $adminModel->adminDetail($param);
        return $result;
    }

    /**
     * 角色详情
     */
    public function  role_detail(){
        $admin_id = $this->app->make('admin_id');
        $param  =  request()->param();
        $param['admin_id'] = $admin_id;
        $roleModel =  new Roles();
        $result = $roleModel->roleDetail($param);
        return $result;
    }

    /**
     * 删除权限
     */
    public function  del_permission(){
        $admin_id = $this->app->make('admin_id');
        $param  =  request()->param();
        $param['admin_id'] = $admin_id;
        $permissionsModel =  new Permissions();
        $result = $permissionsModel->delPermission($param);
        return $result;
    }

    /**
     * 权限列表
     */
    public function  permission_list(){
        $admin_id = $this->app->make('admin_id');
        $param  =  request()->param();
        $param['admin_id'] = $admin_id;
        $permissionsModel =  new Permissions();
        $result = $permissionsModel->permissionList($param);
        return $result;
    }

    /**
     * 获取登陆用户权限列表
     */
    public function  login_admin_permission(){
        $admin_id = $this->app->make('admin_id');
        $param  =  request()->param();
        $param['admin_id'] = $admin_id;
        $permissionsModel =  new Permissions();
        $result = $permissionsModel->loginAdminPermission($param);
        return $result;
    }

    /**
     * 获取角色权限列表
     */
    public function  role_permission_list(){
        $admin_id = $this->app->make('admin_id');
        $param  =  request()->param();
        $param['admin_id'] = $admin_id;
        $permissionsModel =  new Permissions();
        $result = $permissionsModel->rolePermissionList($param);
        return $result;
    }

    /**
     * 获取管理员信息
     */
    public function  get_admin_info(){
        $admin_id = $this->app->make('admin_id');
        $param  =  request()->param();
        $param['admin_id'] = $admin_id;
        $Admin =  new Admin();
        $result = $Admin->getAdminInfo($param);
        return $result;
    }

    /**
     * 获取config列表
     */
    public function  config_list(){
        $admin_id = $this->app->make('admin_id');
        $param  =  request()->param();
        $param['admin_id'] = $admin_id;
        $Admin =  new Config();
        $result = $Admin->configList($param);
        return $result;
    }

    /**
     * 新增编辑config的key和value
     */
    public function  add_edit_config(){
        $admin_id = $this->app->make('admin_id');
        $param  =  request()->param();
        $param['admin_id'] = $admin_id;
        $Admin =  new Config();
        $result = $Admin->addEditConfig($param);
        return $result;
    }


    /**
     * 删除config
     */
    public function  del_config(){
        $admin_id = $this->app->make('admin_id');
        $param  =  request()->param();
        $param['admin_id'] = $admin_id;
        $Admin =  new Config();
        $result = $Admin->delConfig($param);
        return $result;
    }














}
